package com.zy.garbage.config;

import com.zy.garbage.interceptor.JwtInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class LoginConfig implements WebMvcConfigurer {
    @Autowired
    public JwtInterceptor jwtInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        注册JwtInterceptor
        InterceptorRegistration registration = registry.addInterceptor(jwtInterceptor);
        registration.addPathPatterns("/**");
//        指定不拦截的接口
        registration.excludePathPatterns(
                "/user/login",          //登录
                "/user/create",          //注册
                "/user/kaptcha",
                "/user/create",
                "/garbage/allGarbage",
                "/**/*.html",
                "/**/*.js",              //js静态资源
                "/**/*.css",           //css静态资源
                "/**/*.jpg",
                "/**/*.png",
                "/**/*.ico",
                "/**/*.jpeg"
        );
    }
}

